package cn.com.wangluotongxin.merchants.eureka;

import cn.com.wangluotongxin.common.constants.ClientConstants;
import cn.com.wangluotongxin.common.web.AjaxResult;
import cn.com.wangluotongxin.feign.FeignConfiguration;
import cn.com.wangluotongxin.merchants.eureka.fallback.MerchantsClientFallback;
import cn.com.wangluotongxin.merchants.eureka.form.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(name = "wltx-merchants-api", fallback = MerchantsClientFallback.class, configuration = FeignConfiguration.class)
public interface MerchantsClient {

    // 加载商户资源库信息
    @PostMapping("/merchantsapi/inner/merchants/load")
    AjaxResult loadMerchants();

    // 加载商户资源库信息
    @PostMapping("/merchantsapi/inner/merchants/single/load/{merchantsId}")
    AjaxResult loadSingleMerchants(@PathVariable("merchantsId") Integer merchantsId);

    // 初始化账号
    @PostMapping("/merchantsapi/inner/merchants/init/user")
    AjaxResult initMerchantsUser(@RequestParam(ClientConstants.X_TENANT_ID) Integer tenantId, @RequestBody InitMerchantsUserForm form);

    // 同步菜单权限
    @PostMapping("/merchantsapi/inner/menu/init")
    AjaxResult initPlatformMenu(@RequestParam(ClientConstants.X_TENANT_ID) Integer tenantId, @RequestBody InitPlatformMenuForm form);

    // 同步角色权限
    @PostMapping("/merchantsapi/inner/role/init")
    AjaxResult initPlatformRole(@RequestParam(ClientConstants.X_TENANT_ID) Integer tenantId, @RequestBody InitPlatformRoleForm form);

    // 添加菜单
    @PostMapping("/merchantsapi/inner/menu/add")
    AjaxResult addMerchantsMenu(@RequestParam(ClientConstants.X_TENANT_ID) String tenantId, @RequestBody AddMerchantsMenuForm form);

    //编辑菜单
    @PostMapping("/merchantsapi/inner/menu/edit")
    AjaxResult editMerchantsMenu(@RequestParam(ClientConstants.X_TENANT_ID) String tenantId, @RequestBody AddMerchantsMenuEditForm form);

    // 删除菜单
    @PostMapping("/merchantsapi/inner/menu/delete/{menuId}")
    AjaxResult deleteMerchantsMenu(@RequestParam(ClientConstants.X_TENANT_ID) String tenantId, @PathVariable("menuId") Integer menuId);

    // 添加角色
    @PostMapping("/merchantsapi/inner/role/add")
    AjaxResult addMerchantsRole(@RequestParam(ClientConstants.X_TENANT_ID) String tenantId, @RequestBody AddMerchantsRoleForm form);

    // 编辑角色
    @PostMapping("/merchantsapi/inner/role/edit")
    AjaxResult editMerchantsRole(@RequestParam(ClientConstants.X_TENANT_ID) String tenantId, @RequestBody AddMerchantsRoleEditForm form);
}
